package Vista;

import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;


public class VistaEspera extends JFrame{
	 /**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private static final JLabel _labelEspera = new JLabel(new ImageIcon("preloader.gif"));
	private static String _textoEspera = "Cargando base de casos... ";
	private static JFrame _dialogoEspera = new JFrame();
	
	private static VistaEspera _instancia;
	    
	    public static VistaEspera getInstance(){
	        if(_instancia==null)
	            _instancia= new VistaEspera();
	        return _instancia;
	    }
	    private VistaEspera() {
	    }
	    
	    public void initFrameEspera() {
			_dialogoEspera = new JFrame();
			_dialogoEspera.setTitle(_textoEspera);
			_dialogoEspera.setUndecorated(true);
			_dialogoEspera.getContentPane().setLayout(new BorderLayout());
			_dialogoEspera.getContentPane().setCursor(new Cursor(Cursor.WAIT_CURSOR));
			_labelEspera.setText(_textoEspera);
			_dialogoEspera.getContentPane().add(_labelEspera, BorderLayout.CENTER);
			centerWindow(_dialogoEspera);
			_dialogoEspera.pack();
			_dialogoEspera.setVisible(true);

		}
	    private static void centerWindow(JFrame frame)
	    {
		Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
		frame.setBounds((screenSize.width - frame.getWidth()) / 2,
			(screenSize.height - frame.getHeight()) / 2, 
			frame.getWidth(),
			frame.getHeight());
	    }
		public void parar() {
			_dialogoEspera.setVisible(false);
			
		}
}
